from websites.crmebs.api import api, S1
from websites.crmebs.db_util import db_util

"""
{"名称": "", "内配": "", "单位": "", "净含量": "", "零售价": "","卖价": "", "包装尺寸": "", "保质期": "", "大图": ""}
"""
xlspath = r"C:\Users\da\Desktop\1.xls"  # 商品信息表格
srcPath = r'C:\Users\da\Desktop\11\xl\media'  # excel解压后的图片路径
baseImgPath = r'https://xcsm.fun/uploads/attach/detail/dami/'  # 商品图片目录

if __name__ == '__main__':
    value = input("1、插入SQL测试\n2、开始插入商品数据\n3、添加商品评论\n4、创建文件夹，并移动图片\n5、删除指定类目下商品数据\n请输入上述序号：")
    if value == "1":
        goodsType = input("请输入商品类别ID：")
        mSheet = input("请输入sheet值：")
        db = db_util()
        db.insertGoodsInfo(int(goodsType), S1, xlspath, baseImgPath, debug=True, sheet=int(mSheet))
    elif value == "2":
        goodsType = input("请输入商品类别ID：")
        mSheet = input("请输入sheet值：")
        db = db_util()
        db.insertGoodsInfo(int(goodsType), S1, xlspath, baseImgPath, sheet=int(mSheet))
    elif value == "3":
        serialId = input("\n1、商品类目ID\n2、商品子类目ID\n请输入上述序号：")
        goodId = input("请输入ID：")
        if serialId == "1":
            api().addAppraiseToTable(goodsTypeId=goodId)
        elif serialId == "2":
            api().addAppraiseToTable(goodsChildTypeId=goodId)
    elif value == "4":
        dirStart = input("请输入文件夹起始值：")
        mSheet = input("请输入sheet值：")
        db = db_util()
        db.removeGoodsImg(xlspath, dirStart, sheet=int(mSheet), excelImgPath=srcPath)
        print("创建完成！")
    elif value == "5":
        db = db_util()
        db.deleteGoods([185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200])
        print("操作完成！")

    # db.writeFileForDB(CHA_YE)
    # db_util().rebuildDB()
    # db_util().rebuildDB(tableName=["eb_store_order_cart_info", "eb_store_product_reply"])
